package com.ruoyi.coal.modules.publicAPI.controller;


import com.ruoyi.coal.common.utils.R;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "Callback", tags = {"回调接口测试"})
@RestController
@RequestMapping({"callback"})
@DataSource(value = DataSourceType.SLAVE)
public class CallbackController {
    @ApiOperation(value = "回调接口测试", notes = "回调接口测试")
    @GetMapping({"/scanComplete"})
    public R scanComplete(@RequestParam("uuid") String uuid, @RequestParam("code") Integer code) {
        System.out.println(uuid);
        System.out.println(code);
        if (code.intValue() == 0)
            return R.ok("雷达扫描成功，回调成功！");
        return R.error("雷达扫描成功，回调成功！");
    }

    @ApiOperation(value = "回调接口测试", notes = "回调接口测试")
    @GetMapping({"/timedComplete"})
    public R scanCompleteTimed(@RequestParam("coalYardId") Integer coalYardId, @RequestParam("code") Integer code, @RequestParam("datetime") String datetime) {
        System.out.println(coalYardId);
        System.out.println(code);
        System.out.println(datetime);
        if (code.intValue() == 0)
            return R.ok("雷达扫描成功，回调成功[煤场id：" + coalYardId + ",datetime:" + datetime + "]");
        if (code.intValue() == 500)
            return R.error("雷达扫描成功，回调成功[煤场id："+ coalYardId + ", datetime:" + datetime + "]");
        return R.error("雷达扫描成功，回调成功[煤场id："+ coalYardId + ", datetime:" + datetime + "]");
    }
}
